package com.vader.springcloud.controller;

import com.vader.springcloud.service.HystrixService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author kaivader
 */
@RestController
@Slf4j
@RequestMapping("/hystrix")
public class HystrixController {

    @Resource
    private HystrixService hystrixService;

    @GetMapping("/ok/{id}")
    public String ok(@PathVariable Integer id) {
        return hystrixService.paymentInfoOk(id);
    }

    @GetMapping("/timeout/{id}")
    public String timeOut(@PathVariable Integer id) {
        return hystrixService.paymentInfoTimeOut(id);
    }

    @GetMapping("/circuit/{id}")
    public String circuit(@PathVariable Integer id){
        return hystrixService.circuitBreak(id);
    }
}
